package tp.pr4.items;

import tp.pr4.NavigationModule;
import tp.pr4.RobotEngine;

/**
 * The superclass of every type of item. It contains the common 
 * information for all the items and it defines the interface that the items must match
 * @author Alvaro Saez Hernando
 * @author Noel Clemente Montero 
 */
public abstract class Item {
	
	private String id;
	private String description;

	/**
	 * Builds an item from a given identifier and description
	 * @param id Item identifier
	 * @param description Item description
	 */
	public Item(String id,String description){
		this.id = id;
		this.description = description;
	}
	
	
	/**
	 * Checks if the item can be used. Subclasses must override this method
	 * @return true if the item can be used
	 */
	public abstract boolean canBeUsed();
	
	/**
	 * Try to use the item with a robot in a given place. It returns whether 
	 * the action was completed. Subclasses must override this method
	 * @param r The robot that uses the item
	 * @param nav The Place where the item is used
	 * @return true if the action was completed. Otherwise, it returns false
	 */
	public abstract boolean use(RobotEngine r,NavigationModule nav);
	
	/**
	 * Return the item identifier
	 * @return The item identifier
	 */
	public String getId(){
		return this.id;		
	}
	
	/**
	 * Generates a String with the Item description
	 */
	public String toString(){
		return ("WALL·E says: "+ this.id +": "+ this.description);
	}	

}
